var express = require('express');
var router = express.Router();
var mongoose = require('mongoose');
/* GET home page. */
mongoose.connect('mongodb://127.0.0.1"27017/myblog', { useNewUrlParser: true })
const db = mongoose.connection
db.once('open', function() {
  console.log('连接成功');
})
db.on('error', function(error) {
  console.log('连接失败' + error);
});
db.on('disconnected', function () {
  console.log('连接断开');
})

router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

module.exports = router;
